using System;

namespace ActivUFRJ.Classes.Artefato
{
    public class DBFormato : Connection.MySQL
    {
        public DBFormato() : base(ref Connection.DBConnection.myConnection)
        {

        }

        private void FillFormato(Formato formato)
        {
            formato.ID = Convert.ToInt32(TableGetValue("AF_ID"));
            formato.Descricao = Convert.ToString(TableGetValue("AF_Descricao"));
            formato.LinkImagem = Convert.ToString(TableGetValue("AF_LINK_IMAGEM"));
        }


        internal void CarregarFormato(Formato formato)
        {
            try
            {
                string SQL = "SELECT * from artefato_formatos where AF_ID = " + formato.ID.ToString();

                this.SetSQL(SQL);
                if (!this.IsTableOver())
                {
                    FillFormato(formato);
                }
                this.Dispose();
            }
            catch (Exception ex)
            {

            }
        }

        internal System.Data.DataTable GetFormatosDT()
        {
            try
            {
                string SQL = "SELECT * FROM artefato_formatos";

                this.SetSQL(SQL);
                return this.ReturnTable();
            }
            catch (Exception ex)
            {
                return null;
            }
        }
    }
}
